<script>
import { normal_option } from "../common";
import Base from "./Base";

export default {
  name: "ChartPiePine",
  mixins: [Base],
  data() {
    return {
      defaultOption: {
        ...normal_option,
        ...{
          grid: {
            left: 20,
            right: 20,
            bottom: 40,
            top: 20,
          },
          legend: {
            show: false,
          },
        },
        color: [
          "#448EF7",
          "#72C141",
          "#E69137",
          "#E13C3A",
          "#ea7ccc",
          "#fc8452",
          "#fac858",
          "#37A2DA",
          "#329DA5",
          "#D3631B",
        ],
        tooltip: { show: true },
        series: [
          {
            type: "pie",
            radius: ["50%", "75%"],
            center: ["50%", "50%"],
          },
        ],
      },
    };
  },
  computed: {
    option: function () {
      return {
        ...this.defaultOption,
        dataset: {
          dimensions: this.dataset.dimensions,
          source: this.dataset.source.reduce((r, c) => {
            r.push({
              ...c,
              tooltip_value: c[this.dataset.dimensions[1]],
            });
            return r;
          }, []),
        },
      };
    },
  },
};
</script>
